/*
 * @Author: wangqizhang
 * @Date: 2024-04-26 15:30:28
 * @LastEditors: wangqizhang
 * @LastEditTime: 2024-04-27 15:37:45
 * @FilePath: /suixinji-server/db/connect.js
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
const { Sequelize } = require('sequelize');
const { getNormalConfig } = require('../config/config');
const VAR_HOST = getNormalConfig('VAR_HOST');
const VAR_USERNAME = getNormalConfig('VAR_USERNAME');
const VAR_PASSWORD = getNormalConfig('VAR_PASSWORD');
const VAR_DBNAME = getNormalConfig('VAR_DBNAME');
const seq = new Sequelize(VAR_DBNAME, VAR_USERNAME, VAR_PASSWORD, {
  host: VAR_HOST,
  dialect: 'mysql',
});
seq
  .authenticate()
  .then(() => {
    console.log('数据库连接成功');
  })
  .catch((err) => {
    console.log('数据库连接失败', err);
  });
module.exports = seq;
